/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.yogi.webframework.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Yogi
 */
@Entity
@Table(name = "t_product_images")
@NamedQueries({
    @NamedQuery(name = "ProductImages.findAll", query = "SELECT p FROM ProductImages p"),
    @NamedQuery(name = "ProductImages.findByAngle", query = "SELECT p FROM ProductImages p WHERE p.productImagesPK.angle = :angle"),
    @NamedQuery(name = "ProductImages.findByTProductId", query = "SELECT p FROM ProductImages p WHERE p.productImagesPK.tProductId = :tProductId"),
    @NamedQuery(name = "ProductImages.findByImageSrc", query = "SELECT p FROM ProductImages p WHERE p.imageSrc = :imageSrc")})
public class ProductImages implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ProductImagesPK productImagesPK;
    @Column(name = "IMAGE_SRC")
    private String imageSrc;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "productImages")
    private List<ProductPart> productPartList;
    @JoinColumn(name = "T_PRODUCT_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Product product;

    public ProductImages() {
    }

    public ProductImages(ProductImagesPK productImagesPK) {
        this.productImagesPK = productImagesPK;
    }

    public ProductImages(int angle, int tProductId) {
        this.productImagesPK = new ProductImagesPK(angle, tProductId);
    }

    public ProductImagesPK getProductImagesPK() {
        return productImagesPK;
    }

    public void setProductImagesPK(ProductImagesPK productImagesPK) {
        this.productImagesPK = productImagesPK;
    }

    public String getImageSrc() {
        return imageSrc;
    }

    public void setImageSrc(String imageSrc) {
        this.imageSrc = imageSrc;
    }

    public List<ProductPart> getProductPartList() {
        return productPartList;
    }

    public void setProductPartList(List<ProductPart> productPartList) {
        this.productPartList = productPartList;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productImagesPK != null ? productImagesPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductImages)) {
            return false;
        }
        ProductImages other = (ProductImages) object;
        if ((this.productImagesPK == null && other.productImagesPK != null) || (this.productImagesPK != null && !this.productImagesPK.equals(other.productImagesPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.yogi.webframework.model.ProductImages[productImagesPK=" + productImagesPK + "]";
    }

}
